#include <regex>
#include <string.h>
#include "regex11.h"

int regex_search(char *input, char *regex, char *match) {
  std::regex re(regex);
  std::cmatch cm;
  if (std::regex_search(input, cm, re) && cm.size() > 0) {
    strncpy(match, cm[0].first, cm[0].second - cm[0].first);
    match[cm[0].second - cm[0].first] = 0;
    return cm[0].first - input;
  }
  return -1;
}
